<template>
  <!-- 海报 -->
  <div class="poster" :class="widgetData.isShow==0?'flex':''">
    <template v-for="(item, index) in widgetData.value">
      <div class="image" :key="index" :id="item.siteId"
        :class="{'comBorder':comClass=='a'+index}"
        :style="{ width:`${widgetData.detail.width}px`, height:`${widgetData.detail.height}px`}"
        @click="handleClick($event,widgetData,item,'a'+index)">
        <!-- 热力图 -->
        <template v-for="(ele,idx) in mapData">
          <div v-if="ele.sitePageId == item.siteId" :key="idx+'a'" class="mark" 
            :style="{background:`#${ele.color}`,opacity:0.9}">
            <div>
              <div class="name">PV：{{ele.exposurePv}}</div>
              <div class="name">UV：{{ele.exposureUv}}</div>
            </div>
            <div class="level">Lv.{{ele.level}}</div>
          </div>
        </template>
        <!-- 组件 -->
        <template v-if="item.url!=''">
          <img :src="item.url">
        </template>
        <template v-else>
          <div class="image-null"><i class="el-icon-picture"></i></div>
        </template>
        <i @click.stop="deleteItem($event,widgetData,item,index)" class="el-icon-error"></i>
      </div>
    </template>
  </div>
</template>

<script>
export default {
  name: "poster",
  props: {
    widgetData: {
      type: Object,
      required: true
    },
    comClass:{
      type: null,
      default: null
    },
    // 热力图
    mapData:{
      type: Array,
      default: () => []
    }
  },
  data () {
    return {}
  },
  methods: {
    // 属性
    handleClick(e,items,item,idx){
      this.$emit('detailRecomm',e,items,item,idx)
    },
    // 删除
    deleteItem(e,items,item,index){
      this.$emit('deleteItem',e,items,item,index)
    },
  },
}
</script>

<style lang="less" scoped>
.poster {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: row;
  .image{
    width: 100%;
    height: 100%;
    margin: 10px;
    position: relative;
    // 热力图
    .mark{
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      padding: 10px 15px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      .name{
        color: #ffffff;
      }
      .level{
        color: #ffffff;
        text-align: right;
      }
    }
    &:hover{
      .el-icon-error{
        display: block;
      }
    }
    .el-icon-error{
      position: absolute;
      right: -10px;
      top: -6px;
      color: red;
      font-size: 25px;
      cursor: pointer;
      display: none;
      z-index: 9999;
    }
  }
  .image-null{
    background: #ffffff;
    height: 100%;
    font-size: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #c1c1c1;
    width: 100%;
  }
  .comBorder{
    box-shadow: rgba(202,38,250,0.8) 0px 0px 10px 5px;
  }
  // 锚点定位
  .anchor{
    box-shadow: 1px 1px 10px 10px red;
  }
}
.flex{
  flex-flow: wrap;
  align-content: flex-start;
}
</style>